package com.springboot.template.controller;

import com.springboot.template.service.AsyncService;
import com.springboot.template.service.ThreadPoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/async")
public class AsyncController {

    @Autowired
    AsyncService asyncService;

    @Autowired
    ThreadPoolService threadPoolService;

    @GetMapping("/get")
    public String async() {
        asyncService.asyncMethod();
        return "async 请求成功";
    }

    @GetMapping("/pool")
    public String asyncPool() {
        for (int i = 0; i < 7; i++) {
            threadPoolService.asyncMethod();
        }
        return "asyncPool 请求成功";
    }

}
